﻿using QuizConsole.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuizConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var Db = new QuizContext())
            {
                Db.SaveChanges();
                // Db.Questions.Add(AddQuestion());

               

                foreach (var question in Db.Questions)
                {
                    Console.WriteLine(question.Term);
                    foreach (var answer in question.Answers)
                    {
                        Console.WriteLine("\t" + answer.Term);
                    }
                }
            }

            Console.WriteLine("OK");

            Console.ReadKey();
        }

        private static Question AddQuestion()
        {
            var q = new Question();
            q.Id = Guid.NewGuid();

            Console.Write("Question: ");
            q.Term = Console.ReadLine();

            Console.Write("Value: ");
            q.Value = int.Parse(Console.ReadLine());

            Console.Write("\tAnswers count: ");
            int count = int.Parse(Console.ReadLine());

            q.Answers = new List<Answer>();

            for (int i = 0; i < count; i++)
            {
                var answer = new Answer();

                answer.Id = Guid.NewGuid();

                Console.Write("Answer: ");
                answer.Term = Console.ReadLine();

                Console.Write("Is Correct: ");
                answer.IsCorrect = bool.Parse(Console.ReadLine());

                q.Answers.Add(answer);
            }

            return q;
        }
    }
}
